feat(autocomplete): rank slash commands by most-recently-used - #29
Conversation
Add a persistent MRU store that records executed slash commands and boosts their position in autocomplete search results using a soft-decay recency score. Empty `/` menus keep registry order unchanged.
MRU data previously lived in a standalone `slash_mru.json` file. This moves it into the `slash_mru` prefs key in `data.db`, adds automatic migration from the legacy sidecar, and ensures the popup-accept path touches MRU for commands submitted via autocomplete.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Review:
|
| File | Change |
|---|---|
src/autocomplete/mru.rs |
New SlashMru store (JSON, cap 200, soft-decay ranking) |
src/autocomplete/command.rs |
Wire MRU into search sort; touch_mru; 2 new tests |
src/autocomplete/mod.rs |
Export mru |
src/app.rs |
touch_mru on process_command_input; safer autocomplete fallback |
Regressions?
None material. Equal-score name tie-break is already ascending (a.name.cmp(&b.name)). Empty / keeps registry order. Exact/prefix match priority unchanged.
Low residual risk:
- Corrupt/missing
slash_mru.json→ start fresh (handled) - Persist is best-effort non-atomic
fs::write(corrupt-on-crash → recovered next load) - Touch only when
input.autocompleteisSome(fallback path won’t record MRU)
Checks run (read-only / temp worktree, current checkout untouched):
cargo test autocomplete::→ 30 passed (incl.search_ranks_recently_used_first,empty_query_keeps_registry_order_even_with_mru, allmru::tests)- No merge conflicts vs
main gh pr checks/ GraphQL status could not be resolved from this environment
Review correction: an earlier draft flagged a descending name tie-break; re-checked commit
9d2af7d— it is ascending. Confidence bumped accordingly.
Migrations?
No. Adds a new JSON file (~/.local/state/crabcode/slash_mru.json or $XDG_STATE_HOME/crabcode/...). Does not touch SQLite prefs schema.
Checklist before merge
- CI green on #106 (couldn’t verify locally via
gh) - Manual smoke: execute
/compact-mode, then type/comp→compact-moderanks abovecompact - Confirm empty
/still matches registry order after several touches - Optional: verify
slash_mru.jsonappears under data dir after first command
Confidence bumps
| Action | New score |
|---|---|
| 4.5/5 ← current | |
| CI green + short persist round-trip test (write → reload → score) | 5/5 |
Current 4.5/5: feature + tests look good; remaining gap is unverified CI + no disk I/O persist test.
Add a persistent MRU store that records executed slash commands and boosts their position in autocomplete search results using a soft-decay recency score. Empty
/menus keep registry order unchanged.